package com.ruoyi.web.controller.hbs;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.hbs.domain.HbsBusinessMapping;
import com.ruoyi.hbs.service.HbsBusinessMappingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * hbs_商业匹配控制Controller
 * 
 * @author wl
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/hbs/hbsBusinessMapping")
public class HbsBusinessMappingController extends BaseController
{
    @Autowired
    private HbsBusinessMappingService hbsBusinessMappingService;

    /**
     * 查询hbs_商业匹配控制列表
     */
    @PreAuthorize("@ss.hasPermi('hbs:hbsBusinessMapping:list')")
    @GetMapping("/list")
    public TableDataInfo list(HbsBusinessMapping hbsBusinessMapping)
    {
        startPage();
        List<HbsBusinessMapping> list = hbsBusinessMappingService.selectHbsBusinessMappingList(hbsBusinessMapping);
        return getDataTable(list);
    }

    /**
     * 导出hbs_商业匹配控制列表
     */
    @PreAuthorize("@ss.hasPermi('hbs:hbsBusinessMapping:export')")
    @Log(title = "hbs_商业匹配控制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HbsBusinessMapping hbsBusinessMapping)
    {
        List<HbsBusinessMapping> list = hbsBusinessMappingService.selectHbsBusinessMappingList(hbsBusinessMapping);
        ExcelUtil<HbsBusinessMapping> util = new ExcelUtil<HbsBusinessMapping>(HbsBusinessMapping.class);
        util.exportExcel(response, list, "hbs_商业匹配控制数据");
    }

    /**
     * 获取hbs_商业匹配控制详细信息
     */
    @PreAuthorize("@ss.hasPermi('hbs:hbsBusinessMapping:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hbsBusinessMappingService.getById(id));
    }

    /**
     * 新增hbs_商业匹配控制
     */
    @PreAuthorize("@ss.hasPermi('hbs:hbsBusinessMapping:add')")
    @Log(title = "hbs_商业匹配控制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HbsBusinessMapping hbsBusinessMapping)
    {
        return toAjax(hbsBusinessMappingService.save(hbsBusinessMapping));
    }

    /**
     * 修改hbs_商业匹配控制
     */
    @PreAuthorize("@ss.hasPermi('hbs:hbsBusinessMapping:edit')")
    @Log(title = "hbs_商业匹配控制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HbsBusinessMapping hbsBusinessMapping)
    {
        return toAjax(hbsBusinessMappingService.updateById(hbsBusinessMapping));
    }

    /**
     * 删除hbs_商业匹配控制
     */
    @PreAuthorize("@ss.hasPermi('hbs:hbsBusinessMapping:remove')")
    @Log(title = "hbs_商业匹配控制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hbsBusinessMappingService.removeByIds(Arrays.asList(ids)));
    }
}
